package com.codi.fundData.dao.impl;

import com.codi.base.dao.plugin.page.PageView;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.codi.base.dao.BaseDAOImpl;
import com.codi.fundData.dao.FundMMYieldPerformanceDao;
import com.codi.fundData.domain.FundMMYieldPerformance;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author shi.pengyan
 * @date 2016年11月17日 下午3:58:48
 */
@Repository("fundMMYieldPerformanceDao")
public class FundMMYieldPerformanceDaoImpl extends BaseDAOImpl<FundMMYieldPerformance> implements
        FundMMYieldPerformanceDao {

    @Override
    public FundMMYieldPerformance selectFundMMYieldPerformace(FundMMYieldPerformance record) {
        return this.getObject(generateStatement("selectMMYiedlPerformaceLatest"), record);
    }

    @Override
    public FundMMYieldPerformance selectFundMMYieldPerformaceList(Integer innerCode) {
        // TODO
        return null;
    }

    @Override
    public List<Map<String, Object>> selectOneYearData(Integer innerCode) {
        return getSqlSession().selectList(generateStatement("selectOneYearData"), innerCode);
    }

    @Override
    public Page<Map<String, Object>> queryPages(Pageable pageable, Integer innerCode) {
        PageView pageView = this.getPageView(pageable.getPageNumber(), pageable.getPageSize());

        Map<String, Object> map = new HashMap<>();
        map.put("pageView", pageView);

        map.put("innerCode", innerCode);

        List<Map<String, Object>> cashes = getSqlSession().selectList(generateStatement("queryMMPages"), map);

        return new PageImpl<Map<String, Object>>(cashes, pageable, pageView.getRowCount());
    }

}
